﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DeSleeper.Client.Framework;

namespace DeSleeper.Client
{
	/// <summary>
	/// Interaction logic for MainView.xaml
	/// </summary>
	public partial class MainView : PageViewBase<MainViewModel>
	{
	    #region ServiceExecutableAvailable Dependency Property

	    /// <summary>
	    /// 
	    /// </summary>
	    public bool ServiceExecutableAvailable
	    {
	        get { return (bool) GetValue(ServiceExecutableAvailableProperty); }
	        set { SetValue(ServiceExecutableAvailableProperty, value); }
	    }

	    /// <summary>
	    /// <see cref="ServiceExecutableAvailable"/> Dependency Property.
	    /// </summary>
	    public static readonly DependencyProperty ServiceExecutableAvailableProperty =
	        DependencyProperty.Register(
	            "ServiceExecutableAvailable",
	            typeof (bool),
	            typeof (MainView));
	    #endregion


		public MainView()
		{
			if (File.Exists("DeSleeper.ServiceHost.exe"))
				ServiceExecutableAvailable = true;

			InitializeComponent();
			Loaded += loaded;
		}

		void loaded(object sender, RoutedEventArgs e)
		{
			frame.NavigationService.Navigating += MainWindow.NavigationServiceNavigating;
			frame.NavigationService.Navigated += MainWindow.NavigationServiceNavigated;
		}

		private void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			var tabItem = tabControl.SelectedItem as TabItem;
			frame.Navigate(tabItem.Tag as Uri);
		}
	}
}
